package com.eqs.enterprisequestionnaire.controller;

import com.eqs.enterprisequestionnaire.result.R;
import com.eqs.enterprisequestionnaire.service.TimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("timeAnalysis")
public class TimeController {
    @Autowired
    TimeService timeService;

    //返回问卷的平均完成时间
    @GetMapping("/averageTime/{questionnaireId}")
    public R averageFinishedTime(@PathVariable Integer questionnaireId){
        return R.success(timeService.averageFinishedTime(questionnaireId));
    }
    //返回时间段填写人数
    @GetMapping("/timePeriod/{questionnaireId}")
    public R ResponsesByTimePeriod(@PathVariable Integer questionnaireId){
        return R.success(timeService.getResponsesByTimePeriod(questionnaireId));
    }

    //返回一周每天的填写量
    @GetMapping("/dayPeriod/{questionnaireId}")
    public R ResponsesByDay(@PathVariable Integer questionnaireId){
        return R.success(timeService.getResponsesByDayOfWeek(questionnaireId));
    }
}
